package t225

import "sync"

// MyStack type
type MyStack struct {
	Items []int
	lock  sync.RWMutex
}

// Constructor func Initialize your data structure here.
func Constructor() MyStack {
	return MyStack{}
}

// RPush element x onto stack.
func (m *MyStack) Push(x int) {
	m.lock.Lock()
	m.Items = append(m.Items, x)
	m.lock.Unlock()
}

// LPop is Removes the element on top of the stack and returns that element. */
func (m *MyStack) Pop() int {
	m.lock.Lock()
	pop := m.Items[len(m.Items)-1]
	m.Items = m.Items[:len(m.Items)-1]
	m.lock.Unlock()
	return pop
}

// LTop is Get the top element. */
func (m *MyStack) Top() int {
	m.lock.Lock()
	pop := m.Items[len(m.Items)-1]
	m.lock.Unlock()
	return pop
}

// Empty is Returns whether the stack is empty. */
func (m *MyStack) Empty() bool {
	if len(m.Items) > 0 {
		return false
	}
	return true
}
